package com.shtel.paas.monitorcenter.autodiscover.util;

import java.util.List;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

@Component
public class HostId {
	
	public JSONObject toTree(List<String> jobs){
		
		String data = "{\"name\":\"未配置主机名\", \"children\":[";
		
		for(int i = 1; i<=jobs.size();i++){
			
			data = data + "{" + "\"" + "name" + "\"" + ":" + "\"" + jobs.get(i-1) +"\"" +"}";	
			if(i<jobs.size()){
				
				data = data + ",";				
			}
		}
		
		data = data + "]" + "}";
				
		
		JSONObject result = JSON.parseObject(data);
		
		return result;
		
		
	}
	
	
}
